//
//  BalancesView.m
//  cityStar
//
//  Created by joyban on 14-12-27.
//  Copyright (c) 2014年 tiny. All rights reserved.
//

#import "UIColor+FlatUI.h"
#import "BalancesView.h"
#import "UIColor+FlatUI.h"

@implementation BalancesView

-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setDrawView];
    }
    return self;
}

-(void)setDrawView
{
    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(34, 19, 203, 42)];
    self.nameLabel.text = @"修改昵称";
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    self.nameLabel.font = [UIFont systemFontOfSize:16];
    [self addSubview:self.nameLabel];
    
    self.layer.cornerRadius = 4;
    
    self.backgroundColor = [UIColor colorFromHexCode:@"e6e6e6"];
    self.textOne = [[UITextField alloc]initWithFrame:CGRectMake(24, 77, 244, 41)];
    self.textOne.placeholder = @"请输入提现金额";
    self.textOne.textAlignment = NSTextAlignmentCenter;
    self.textOne.font = [UIFont systemFontOfSize:16];
    self.textOne.borderStyle = UITextBorderStyleNone;
    self.textOne.backgroundColor = [UIColor whiteColor];
    self.textOne.layer.cornerRadius = 3;
    self.textOne.returnKeyType = UIReturnKeyDone;
    self.textOne.delegate = self;
    [self addSubview:self.textOne];
    
    self.textTwo = [[UITextField alloc]initWithFrame:CGRectMake(25, 131, 244, 41)];
    self.textTwo.placeholder = @"请输入开户名称";
    self.textTwo.font = [UIFont systemFontOfSize:16];
    self.textTwo.textAlignment = NSTextAlignmentCenter;
    self.textTwo.borderStyle = UITextBorderStyleNone;
    self.textTwo.backgroundColor = [UIColor whiteColor];
    self.textTwo.layer.cornerRadius = 3;
    self.textTwo.returnKeyType = UIReturnKeyDone;
    self.textTwo.delegate = self;
    [self addSubview:self.textTwo];
    
    self.textThree = [[UITextField alloc]initWithFrame:CGRectMake(24, 186, 244, 41)];
    self.textThree.placeholder = @"请输入银行账户姓名";
    self.textThree.font = [UIFont systemFontOfSize:16];
    self.textThree.textAlignment = NSTextAlignmentCenter;
    self.textThree.borderStyle = UITextBorderStyleNone;
    self.textThree.backgroundColor = [UIColor whiteColor];
    self.textThree.layer.cornerRadius = 3;
    self.textThree.returnKeyType = UIReturnKeyDone;
    self.textThree.delegate = self;
    [self addSubview:self.textThree];
    
    self.textFour = [[UITextField alloc]initWithFrame:CGRectMake(25, 241, 244, 41)];
    self.textFour.placeholder = @"输入银行卡号";
    self.textFour.font = [UIFont systemFontOfSize:16];
    self.textFour.textAlignment = NSTextAlignmentCenter;
    self.textFour.borderStyle = UITextBorderStyleNone;
    self.textFour.backgroundColor = [UIColor whiteColor];
    self.textFour.layer.cornerRadius = 3;
    self.textFour.returnKeyType = UIReturnKeyDone;
    self.textFour.delegate = self;
    [self addSubview:self.textFour];
    
    self.Returenbtn = [[UIButton alloc]initWithFrame:CGRectMake(25, 312, 120, 35)];
    [self.Returenbtn setTitle:@"确认" forState:UIControlStateNormal];
    self.Returenbtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [self.Returenbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.Returenbtn setBackgroundImage:[UIImage imageNamed:@"shortRedButton"] forState:UIControlStateNormal];
    [self.Returenbtn setBackgroundImage:[UIImage imageNamed:@"shortRedButton_touch"] forState:UIControlStateHighlighted];
    self.Returenbtn.layer.cornerRadius = 4;
    [self.Returenbtn addTarget:self action:@selector(Returen_Action:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.Returenbtn];
    
    self.Cancelbtn = [[UIButton alloc]initWithFrame:CGRectMake(150, 312, 120, 35)];
    [self.Cancelbtn setTitle:@"取消" forState:UIControlStateNormal];
    self.Cancelbtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [self.Cancelbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.Cancelbtn setBackgroundImage:[UIImage imageNamed:@"shortGaryButton"] forState:UIControlStateNormal];
    [self.Cancelbtn setBackgroundImage:[UIImage imageNamed:@"shortGaryButton_touch"] forState:UIControlStateHighlighted];    self.Cancelbtn.layer.cornerRadius = 4;
    [self.Cancelbtn addTarget:self action:@selector(Cancle_ACtion:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.Cancelbtn];
    
    
//    UIToolbar * topView = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 30)];
//    [topView setBarStyle:UIBarStyleDefault];
//    
//    UIBarButtonItem * btnSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
//    
//    UIBarButtonItem * doneButton = [[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonItemStyleDone target:self action:@selector(dismissKeyBoard)];
//    
//    NSArray * buttonsArray = [NSArray arrayWithObjects:btnSpace,doneButton,nil];
//    
//    
//    [topView setItems:buttonsArray];
//    [self.textOne setInputAccessoryView:topView];
//    [self.textTwo setInputAccessoryView:topView];
//    [self.textThree setInputAccessoryView:topView];
//    [self.textFour setInputAccessoryView:topView];
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
     [textField resignFirstResponder];
    return YES;
}

-(void)dismissKeyBoard
{
    [self.textOne resignFirstResponder];
    [self.textTwo resignFirstResponder];
    [self.textThree resignFirstResponder];
    [self.textFour resignFirstResponder];
}

-(void)Returen_Action:(UIButton *)sender
{
    [self dismissKeyBoard];
    [self.delegate senderReturnClick:sender];
}

-(void)Cancle_ACtion:(UIButton *)sender
{
    [self dismissKeyBoard];
    [self.delegate senderCancleoactClick:sender];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
